<?php 
if (!$GET_service || $GET_service != "getSetores") {
	die("<script>window.location='../?'</script>");
}

if (!isset($_SESSION['loggeduser']) || $_SESSION['loggeduser']['id'] == "") {
	die("<script>window.location='./?'</script>");
}
header('Content-Type: text/json; charset=UTF-8');

$db->begin();
$result = $db->select("SELECT * FROM setor");

if ($result) {
		$setor = array();
		while($linha = mysql_fetch_array($result)){
			array_push($setor, $linha);
		}
		
		//die(is_array($setor));
		die(json_encode($setor));
	} else {
		die(json_encode(Array("estado" => "ERRO")));
	}	
?>